<?php

/**
 * My Application bootstrap file.
 */
use Nette\Diagnostics\Debugger;
use Nette\Application\Routers\Route;

// Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
@header('X-Author: Jan Voracek'); // @ - headers may be sent
require LIBS_DIR . '/Nette/loader.php';

$loader = new Nette\Loaders\RobotLoader();
$loader->addDirectory(LIBS_DIR);
$loader->addDirectory(APP_DIR);
$loader->setCacheStorage(new \Nette\Caching\Storages\FileStorage(TEMP_DIR . '/cache'));
$loader->register();

// Enable Nette\Debug for error visualisation & logging
Debugger::$strictMode = TRUE;
Debugger::enable(FALSE);
Debugger::addPanel(new \Tasker\Debug\RulerPanel());

function barDump($var, $title='')
{
	$backtrace = debug_backtrace();
	$file = basename($backtrace[0]['file']);
	$line = $backtrace[0]['line'];
	if($title !== '')
		$title .= ' - ';
	Nette\Diagnostics\Debugger::barDump($var, $title . $file . ' (' . $line .')');
	return $var;
}

function dereferenced_array_value($array, $index){
	return $array[$index];
}

// Load configuration from config.neon file
$configurator = new Tasker\Configurator\Configurator();
$configurator->loadConfig(__DIR__ . '/config.neon');
Nette\Utils\Html::$xhtml = false; // Disable XHTML tags - e.g. use <br> instead of <br />
// Configure application
$application = $configurator->container->application;
$application->errorPresenter = 'Error';
$application->catchExceptions = FALSE;


// Setup router
$application->onStartup[] = function() use ($application)
		{
			$router = $application->getRouter();
			
			$router[] = new Route('index.php', 'NoticeBoard:default', Route::ONE_WAY);
			$router[] = new Route('<module Admin>/<presenter=Default>/<action=default>[/<id>]');
			$router[] = new Route('<presenter=NoticeBoard>/<action=default>[/<id>]');
			
		};



\Nette\Forms\Container::extensionMethod('addCheckboxList', array('\Tasker\Forms\Controls\CheckboxList', 'addCheckboxList'));
\Nette\Forms\Container::extensionMethod('addCheckboxDetailList', array('\Tasker\Forms\Controls\CheckboxDetailList', 'addCheckboxDetailList'));
\Nette\Forms\Container::extensionMethod('addDatePicker', function (\Nette\Forms\Container $container, $name, $label = NULL)
		{
			return $container[$name] = new JanTvrdik\Components\DatePicker($label);
		});
\Nette\Forms\Container::extensionMethod("addDependentSelectBox", "DependentSelectBox\DependentSelectBox::formAddDependentSelectBox");
// Run the application!
$application->run();
